package com.gzhryc.shared_device.cdcz.core.protocol.v1;

import com.gzhryc.common.IDTools;

public class V1_CDCZConstants {

    public static String KEY_CMD = "01";        //命令
    public static String KEY_MSG_ID = "02";     //消息ID
    public static String KEY_MAC = "03";        //设备MAC
    public static String KEY_VERSION = "04";    //版本号
    public static String KEY_CSQ = "05";        //信号强度
    public static String KEY_TIME = "06";       //时间戳，秒
    public static String KEY_MCU_TEMPERATURE = "07";       //MCU温度
    public static String KEY_PLUG_NUM = "08";   //充电卡槽
    public static String KEY_PLUG_SLOT_STATE = "09";    //卡槽状态
    public static String KEY_CHARGE_MODE = "12";       //充电模式，1:按时，2:按量
    public static String KEY_CHARGE_CONTROL = "13";   //控制类型，0:关闭，1:开启
    public static String KEY_SET_CHARGE_TIME = "14";    //充电时间
    public static String KEY_SET_CHARGE_ELECTRICITY = "15"; //最大充电电量

    public static String KEY_POWER = "0B";          //瞬时功率
    public static String KEY_CURRENT = "0C";        //瞬时电流
    public static String KEY_PLUG_ELECTRICITY = "0D";   //已充电量
    public static String KEY_PLUG_CHARGE_TIME = "0E";   //充电时长
    public static String KEY_CHARGE_FINISH_TIME = "2E"; //充电结束时间，单位：秒

    public static String KEY_RESTART_COUNTDOWN = "1F";   //重启倒计时时间

    public static String KEY_PACKAGE_PATH = "1B";       //固定版本包
    public static String KEY_PACKAGE_CRC = "1A";       //固定版本包的CRC值

    public static String KEY_ACK = "0F";    //服务器应答，1：OK，0：失败

    public static String KEY_SIM_ICCID= "48";   //ICCID卡

    //卡槽信息
    public static String KEY_SLOT_1 = "1C";
    public static String KEY_SLOT_2 = "1D";
    public static String KEY_SLOT_3 = "49";
    public static String KEY_SLOT_4 = "4A";
    public static String KEY_SLOT_5 = "4B";
    public static String KEY_SLOT_6 = "4C";
    public static String KEY_SLOT_7 = "61";
    public static String KEY_SLOT_8 = "62";
    public static String KEY_SLOT_9 = "63";
    public static String KEY_SLOT_10 = "64";


    public static String CMD_START_UP = "1010";       //上电
    public static String CMD_ONLINE = "1011";         //断网上线
    public static String CMD_HEARTBEAT = "1001";      //心跳
    public static String CMD_ABNORMAL= "1012";        //卡槽异常上报
    public static String CMD_SEARCH_SLOT = "1003";    //查询卡槽
    public static String CMD_CONTROL = "1007";        //充电控制
    public static String CMD_CHARGE_END = "1004";      //充电结束
    public static String CMD_SEARCH_CONFIG= "100C";    //查询设备配置
    public static String CMD_CONFIG= "100B";           //设备配置
    public static String CMD_FIRMWARE_DOWNLOAD = "1008";  //固件下载
    public static String CMD_FIRMWARE_UP = "1009";        //固件升级
    public static String CMD_RESTART = "100D";         //重启


    public static Integer VALUE_TYPE_HEX = 1;       //16位
    public static Integer VALUE_TYPE_STRING = 2;    //字符串


    public static String getMessageId(){
        String msgId = IDTools.getTimestampNanoID();
        if(msgId.length() > 16){
            msgId = msgId.substring(0,16);
        }else if(msgId.length() < 16){
            msgId = msgId + IDTools.getRandomNumberStr((16 - msgId.length()));
        }
        return msgId;
    }
}
